<?php

class RoomInterceptor  extends C_Interceptor
{
	public function _begin()
	{
	
		//获取当前房间
		if(Zend_Registry::isRegistered('current_room_E')) 
		{
			$this->_response->current_room_E = Zend_Registry::get('current_room_E');
			return ;
		}
		
		$roomid = $this->_request->get("roomid");
		$site_E = Zend_Registry::get('site_E');
		//如果roomid 为空.获取第一个房间当首页.
		if(empty($roomid))
		{
			$current_room_E = Rooms::getBySiteId($site_E->id);
		}
		else 
		{
			$current_room_E = Rooms::getById($roomid);
		}
		//如果没有房间则出错
		if(empty($current_room_E))
		{
			$error_info = "没有房间";
			$jumpurl = $this->_response->getUrl('index', 'error','error',array('error_info'=>$error_info));
			$this->_response->RedirectJump($jumpurl);
		}
		//验证房间是否和site 对应
		
		if($current_room_E->siteid != $site_E->id)
		{
			
			$error_info = "房间和站点不对应";
			$jumpurl = $this->_response->getUrl('index', 'error','error',array('error_info'=>$error_info));
			$this->_response->RedirectJump($jumpurl);
		}
		
		
		$this->_response->current_room_E = $current_room_E;
		Zend_Registry::set('current_room_E',$current_room_E);
			
	}
	public function _end()
	{
		
		
	}
}
?>